package com.we823.cms.common.web.converter;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;

import com.we823.cms.model.sys.ResourceType;

public class StringToResourceType implements Converter<String, ResourceType> {

	private Logger logger = LoggerFactory.getLogger(StringToResourceType.class);
	
	@Override
	public ResourceType convert(String source) {
		logger.debug("[{} converter to resourceType]",source);
		if (StringUtils.isEmpty(source)) {
			return ResourceType.OTHER;
		}
		return ResourceType.parse(source);
	}

}
